﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Biciq.Silverlight.UI
{
    public partial class EditarTarjetaVista : ChildWindow
    {
        public EditarTarjetaVista()
        {
            InitializeComponent();
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void TextBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                var codigo = ((TextBox)sender).Text;
                if (codigo != null && codigo != "")
                {
                    var contexto = this.DataContext as EditarTarjetaVistaModelo;
                    contexto.Tarjeta.codigo = codigo;
                    contexto.AgregarTarjeta();
                    txtCodigo.Focus();
                }
             
            }
        }
    }
}

